@extends('admin/layout')
@push('style')
    <style>
        /** 应用快捷块样式 */
        .console-app-group {
            padding: 16px;
            border-radius: 4px;
            text-align: center;
            background-color: #fff;
            cursor: pointer;
            display: block;
        }

        .console-app-group .console-app-icon {
            width: 32px;
            height: 32px;
            line-height: 32px;
            margin-bottom: 6px;
            display: inline-block;
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
            font-size: 32px;
            color: #69c0ff;
        }

        .console-app-group:hover {
            box-shadow: 0 0 15px rgba(0, 0, 0, .08);
        }

        /** //应用快捷块样式 */

        /** 小组成员 */
        .console-user-group {
            position: relative;
            padding: 10px 0 10px 60px;
        }

        .console-user-group .console-user-group-head {
            width: 32px;
            height: 32px;
            position: absolute;
            top: 50%;
            left: 12px;
            margin-top: -16px;
            border-radius: 50%;
        }

        .console-user-group .layui-badge {
            position: absolute;
            top: 50%;
            right: 8px;
            margin-top: -10px;
        }

        .console-user-group .console-user-group-name {
            line-height: 1.2;
        }

        .console-user-group .console-user-group-desc {
            color: #8c8c8c;
            line-height: 1;
            font-size: 12px;
            margin-top: 5px;
        }

        /** 卡片轮播图样式 */
        .admin-carousel .layui-carousel-ind {
            position: absolute;
            top: -41px;
            text-align: right;
        }

        .admin-carousel .layui-carousel-ind ul {
            background: 0 0;
        }

        .admin-carousel .layui-carousel-ind li {
            background-color: #e2e2e2;
        }

        .admin-carousel .layui-carousel-ind li.layui-this {
            background-color: #999;
        }

        /** 广告位轮播图 */
        .admin-news .layui-carousel-ind {
            height: 45px;
        }

        .admin-news a {
            display: block;
            line-height: 70px;
            text-align: center;
        }

        /** 最新动态时间线 */
        .layui-timeline-dynamic .layui-timeline-item {
            padding-bottom: 0;
        }

        .layui-timeline-dynamic .layui-timeline-item:before {
            top: 16px;
        }

        .layui-timeline-dynamic .layui-timeline-axis {
            width: 9px;
            height: 9px;
            left: 1px;
            top: 7px;
            background-color: #cbd0db;
        }

        .layui-timeline-dynamic .layui-timeline-axis.active {
            background-color: #0c64eb;
            box-shadow: 0 0 0 2px rgba(12, 100, 235, .3);
        }

        .dynamic-card-body {
            box-sizing: border-box;
            overflow: hidden;
        }

        .dynamic-card-body:hover {
            overflow-y: auto;
            padding-right: 9px;
        }

        /** 优先级徽章 */
        .layui-badge-priority {
            border-radius: 50%;
            width: 20px;
            height: 20px;
            padding: 0;
            line-height: 18px;
            border-width: 2px;
            font-weight: 600;
        }
    </style>
@endpush
@section('body')
    <div style="margin-left: 15px;margin-top: 15px; align-content: center;">
        <div class="dropdown-menu dropdown-hover">
            <button class="layui-btn icon-btn">
                &nbsp;{{$coin}} <i class="layui-icon layui-icon-drop"></i></button>
            <ul class="dropdown-menu-nav">
                @foreach($coins as $key=>$item)
                    @if($key==$coin)
                        <li class="disabled"><a><i class="layui-icon layui-icon-star-fill"></i>{{$item}}</a></li>
                    @else
                        <li><a href="?coin={{$key}}"><i class="layui-icon layui-icon-star-fill"></i>{{$item}}</a></li>
                    @endif
                @endforeach
            </ul>
        </div>
        <span style="line-height: 36px;color: #FFB800;display: inline-block;font-weight: bold;margin-left: 10px;"><i
                    class="layui-icon layui-icon-notice"></i>&nbsp;&nbsp;{{$agent_settlement_tips}}</span>
    </div>
    <!-- 正文开始 -->
    <div class="layui-fluid ew-console-wrapper">
        <div class="layui-row layui-col-space15" id="indexApp">
            <div class="layui-col-xs12 layui-col-sm6 layui-col-md3">
                <div class="layui-card">
                    <div class="layui-card-header">
                        昨日总收益<span class="layui-badge layui-badge-green pull-right">日</span>
                    </div>
                    <div class="layui-card-body">
                        <p class="lay-big-font">{{$yesterday_profit}} <span
                                    style="font-size: 24px;line-height: 1;">{{$coin_unit}}</span></p>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs12 layui-col-sm6 layui-col-md3">
                <div class="layui-card">
                    <div class="layui-card-header">
                        全部总收益<span class="layui-badge layui-badge-blue pull-right">月</span>
                    </div>
                    <div class="layui-card-body">
                        <p class="lay-big-font">{{$total_profit}} <span
                                    style="font-size: 24px;line-height: 1;">{{$coin_unit}}</span></p>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs12 layui-col-sm6 layui-col-md3">
                <div class="layui-card">
                    <div class="layui-card-header">
                        未结算收益<span class="layui-badge layui-badge-red pull-right">周</span>
                    </div>
                    <div class="layui-card-body">
                        <p class="lay-big-font">{{$balance}} <span
                                    style="font-size: 24px;line-height: 1;">{{$coin_unit}}</span></p>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs12 layui-col-sm6 layui-col-md3">
                <div class="layui-card">
                    <div class="layui-card-header">
                        在线矿机数
                        <span class="icon-text pull-right" title="指标说明" lay-direction="4" lay-offset="5px,5px">
                        <i class="layui-icon layui-icon-tips"></i>
                    </span>
                    </div>
                    <div class="layui-card-body">
                        <p class="lay-big-font">@{{summary.active_worker_num}} <span
                                    style="font-size: 24px;line-height: 1;">台</span></p>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs12 layui-col-sm6 layui-col-md3">
                <div class="layui-card">
                    <div class="layui-card-header">
                        离线矿机数
                        <span class="icon-text pull-right" title="指标说明" lay-direction="4" lay-offset="5px,5px">
                        <i class="layui-icon layui-icon-tips"></i>
                    </span>
                    </div>
                    <div class="layui-card-body">
                        <p class="lay-big-font">@{{summary.inactive_worker_num}} <span
                                    style="font-size: 24px;line-height: 1;">台</span></p>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs12 layui-col-sm6 layui-col-md3">
                <div class="layui-card">
                    <div class="layui-card-header">
                        10分钟平均算力
                        <span class="icon-text pull-right" title="指标说明" lay-direction="4" lay-offset="5px,5px">
                        <i class="layui-icon layui-icon-tips"></i>
                    </span>
                    </div>
                    <div class="layui-card-body">
                        <p class="lay-big-font">@{{summary.realtime_hash_rate[0]}} <span
                                    style="font-size: 24px;line-height: 1;">@{{summary.realtime_hash_rate[1]}}</span>
                        </p>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs12 layui-col-sm6 layui-col-md3">
                <div class="layui-card">
                    <div class="layui-card-header">
                        24小数平均算力
                        <span class="icon-text pull-right" title="指标说明" lay-direction="4" lay-offset="5px,5px">
                        <i class="layui-icon layui-icon-tips"></i>
                    </span>
                    </div>
                    <div class="layui-card-body">
                        <p class="lay-big-font">@{{ summary.avg_hash_rate_1440[0] }} <span
                                    style="font-size: 24px;line-height: 1;">@{{ summary.avg_hash_rate_1440[1] }}</span>
                        </p>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-row layui-col-space15">
            <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body">
                        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                            <ul class="layui-tab-title">
                                <li class="layui-this">子账号信息</li>
                                <li>每日收益</li>
                                <li>每日收益汇总</li>
                                <li>结算信息</li>
                            </ul>
                            <div class="layui-tab-content">
                                <div class="layui-tab-item layui-show">
                                    <table id="subAccountAgentTable" lay-filter="subAccountAgentTable"></table>
                                </div>
                                <div class="layui-tab-item">
                                    <table id="agentSubAccountProfitTable"
                                           lay-filter="agentSubAccountProfitTable"></table>
                                </div>
                                <div class="layui-tab-item">
                                    <table id="agentProfitTable" lay-filter="agentProfitTable"></table>
                                </div>
                                <div class="layui-tab-item">
                                    <table id="transferTaskTable" lay-filter="transferTaskTable"></table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@stop
@push('script')
    <script type="text/javascript" src="{{url('/admin/assets/js/vue.min.js')}}"></script>
    <script>
        // layui.use(['layer', 'dropdown', 'element'], function () {
        //     var $ = layui.jquery;
        //
        // });
        layui.use(['layer', 'carousel', 'element', 'dropdown'], function () {
            var $ = layui.jquery;
            var layer = layui.layer;
            var carousel = layui.carousel;
            var device = layui.device();

            // 渲染轮播
            carousel.render({
                elem: '#workplaceNewsCarousel',
                width: '100%',
                height: '70px',
                arrow: 'none',
                autoplay: true,
                trigger: device.ios || device.android ? 'click' : 'hover',
                anim: 'fade'
            });

        });
        let indexAppVue = new Vue({
            el: '#indexApp',
            data: {
                summary: {
                    active_worker_num: 0,
                    avg_hash_rate_1440: ["0", ""],
                    inactive_worker_num: 0,
                    realtime_hash_rate: ["0", ""]
                }
            },
            created() {

            },
            methods: {}
        });
    </script>
    <script type="text/javascript">
        layui.use(['layer', 'form', 'table', 'util', 'admin'], function () {
            let listTableInc = new ListTable("{{admin_url($baseRoute.'agentSubAccount')}}?coin={{$coin}}", "subAccountAgentTable");
            listTableInc.lineNumber();
            listTableInc.column("子账号", "name");
            listTableInc.column("分成比例", "ratio");
            listTableInc.column("备注", "remark");
            listTableInc.column("实时算力", "realtime_hash_rate");
            listTableInc.column("24小时平均算力", "avg_hash_rate_1440");
            listTableInc.column("在线/离线", "active_worker_num").tpl(function (d) {
                return d.active_worker_num + "/" + d.inactive_worker_num;
            });
            listTableInc.column("状态", "status_text");
            listTableInc.column("创建时间", "created_at").setWithDateTime();
            listTableInc.config.done = function (res) {
                SystemUtil.resultFilter(res, function () {
                    indexAppVue.summary = res.summary;
                });
            };
            listTableInc.render();
        });
    </script>
    <script type="text/javascript">
        layui.use(['layer', 'form', 'table', 'util', 'admin'], function () {
            layui.use(['layer', 'form', 'table', 'util', 'admin'], function () {
                let listTableInc = new ListTable("{{admin_url('/business/agentSubAccountProfit/pager')}}?coin={{$coin}}", 'agentSubAccountProfitTable');
                listTableInc.lineNumber();
                listTableInc.column("币种", "coin");
                listTableInc.column("子账号", "name");
                listTableInc.column("日期", "day");
                listTableInc.column("子账号收益", "original_profit");
                listTableInc.column("分成比例(%)", "ratio");
                listTableInc.column("代理商收益", "profit");
                listTableInc.render();
            });
        });
    </script>

    <script type="text/javascript">
        layui.use(['layer', 'form', 'table', 'util', 'admin'], function () {
            let listTableInc = new ListTable("{{admin_url('business/agentProfit/pager')}}?coin={{$coin}}", 'agentProfitTable');
            listTableInc.lineNumber();
            listTableInc.column("币种", "coin");
            listTableInc.column("日期", "day");
            listTableInc.column("代理商", "email");
            listTableInc.column("日收益", "profit");
            listTableInc.column("总收益", "total_profit");
            listTableInc.column("未结算收益", "balance");
            listTableInc.column("结算收益", "settlement_profit");
            listTableInc.render();
        });
    </script>
    <script type="text/javascript">
        layui.use(['layer', 'form', 'table', 'util', 'admin', 'upload'], function () {
            let listTableInc = new ListTable("{{admin_url('business/transferTask/pager')}}?coin={{$coin}}", 'transferTaskTable');
            listTableInc.lineNumber();
            listTableInc.column("任务ID", "id");
            listTableInc.column("日期", "day").setWidth(100);
            listTableInc.column("币种", "coin").setWidth(80);
            listTableInc.column("收益", "profit");
            listTableInc.column("钱包", "wallet").setWidth(370);
            listTableInc.column("转账流水", "transfer_no").setWidth(370);
            listTableInc.column("手续费", "handling_fee").setWidth(370);
            listTableInc.column("状态", "status_text").setWidth(80);
            listTableInc.render();
        });
    </script>
@endpush
